<!--
 * @docName: signTheContractPopups.vue
 * @Author: mwl
 * @Date: 2023/9/27
 * @LastEditors: zhongxiong
 * @LastEditTime: 9:34
-->
<template>
  <a-modal width='900px' v-model="signConfig.visible" :title="signConfig.title" :destroyOnClose="true" :footer="false" >
    <!-- <pdfBox style='border: 1px solid #ccc;height: 600px' :url='signConfig.cloudAgreeUrl'></pdfBox> -->
    <p-PreviewShow :model="'page'" :config="{title:'',visible: false, loading: false, width: '50vw',height: '60vh' }" :event="()=>{}" :url='signConfig.cloudAgreeUrl' :isShowWatermark="true" style='border: 1px solid #ccc;height: 600px'></p-PreviewShow>
    <div style='text-align: right; margin: 10px 0;'>
      <a-button ghost type="primary" @click='upload()'>下载授权书</a-button>
      <a-button type="primary" style='margin-left: 10px' @click='handleOk(signConfig.cloudAgreeId)'>签署授权书</a-button>
    </div>
  </a-modal>
</template>

<script>
export default {
  name: 'signTheContractPopups',
  props:['signConfig'],
  data(){
    return{}
  },
  created() {
  },
  mounted() {
  },
  methods:{
    handleOk(){
      this.$emit('popUpsClick',{'name':'howToSign'})
    },
    //下载
    upload() {
      if (this.signConfig.cloudAgreeUrl.includes('jpeg') || this.signConfig.cloudAgreeUrl.includes('png') || this.signConfig.cloudAgreeUrl.includes('jpg') || this.signConfig.cloudAgreeUrl.includes('pdf')) {
        this.AddWatermark.addWatermark(this.signConfig.cloudAgreeUrl).then(res => {
          const a = document.createElement('a')
          a.href = res.url
          a.download = '授权书' + '.' + res.suffix;
          a.click()
          window.URL.revokeObjectURL(res.url);
        })
      } else {
        this.$message.warning('格式不对，无法下载');
      }
    },
  },

}
</script>

<style scoped>

</style>
